<? 
$nrp=$_POST["nrp"];
$kegiatan=$_POST["kegiatan"];
$poin=$_POST["poin"];
$keterangan=$_POST["keterangan"];
if (empty($nrp)) {
	echo " <SCRIPT> alert(\"ERROR ! Anda belum memasukkan NRP.\") </SCRIPT> ";
	mysql_close($conn);
	echo "<script type=\"text/javascript\">";
	echo "history.go(-1)";
	echo "</script>";
	exit;
}
if ($poin==0) {
	echo " <SCRIPT> alert(\"ERROR ! Nilai poin yang dimasukkan tidak boleh nol / kosong.\") </SCRIPT> ";
	mysql_close($conn);
	echo "<script type=\"text/javascript\">";
	echo "history.go(-1)";
	echo "</script>";
	exit;
}
include("../connect.php");
$pilih=mysql_select_db("uwika_skk",$conn);
$sqlstr="SELECT nrp from score where nrp = '$nrp' and kode='$kegiatan'";
$hasil=mysql_query($sqlstr);
list($dobel) = mysql_fetch_row($hasil);
if (!empty($dobel)) {
	$pilih=mysql_select_db("uwika_skk",$conn);
	$sqlstr="update score set poin='$poin', keterangan='$keterangan' where nrp='$nrp' and kode='$kegiatan'";
	$hasil=mysql_query($sqlstr);
	mysql_close($conn);
	echo " <SCRIPT> alert(\"Data lama anda telah diperbaharui.\") </SCRIPT> ";
	echo "<meta http-equiv=\"refresh\" content=\"0; url=set_mahasiswa.php\">";
	echo "Klik <a href=\"set_mahasiswa.php\">disini</a> apabila browser anda berhenti berjalan ...";
} else {
	$pilih=mysql_select_db("uwika_skk",$conn);
	$sqlstr="insert into score (nrp,kode,poin,keterangan) values ('$nrp','$kegiatan','$poin','$keterangan')";
	$hasil=mysql_query($sqlstr);
	mysql_close($conn);
	echo " <SCRIPT> alert(\"Data baru anda telah disimpan.\") </SCRIPT> ";
	echo "<meta http-equiv=\"refresh\" content=\"0; url=set_mahasiswa.php\">";
	echo "Klik <a href=\"set_mahasiswa.php\">disini</a> apabila browser anda berhenti berjalan ...";
}
?>
